package Controller.GestionGroupe;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Controller.BDD.GestionDroitBDD;
import Controller.BDD.GestionGroupeBDD;
import Controller.BDD.GestionRequeteDroit;
import Model.Groupe;
import Model.Utilisateur;

/**
 * Servlet implementation class CreerGroupe
 */
@WebServlet("/SupprimerGroupe")
public class SupprimerGroupe extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SupprimerGroupe() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String urlVue = "";
		
		Enumeration<String>  StringIds = request.getParameterNames();
	
		while(StringIds.hasMoreElements()){
			try {
				GestionGroupeBDD.supprimerGroupeParID(Integer.parseInt(StringIds.nextElement()));
			} catch (Exception e) {
				//messageInformation = e.getMessage();
			}
		}
		
		// Todo: Tester si la supression est ok.
		/*
		request.setAttribute("msg", messageInformation);
		request.getRequestDispatcher(urlVue).forward(request, response);
		*/
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
